#!ipxe

# OpenBSD Operating System
# http://www.openbsd.org

:openbsd_menu
set os {{ releases.openbsd.name }}
set os_arch ${arch}
iseq ${os_arch} x86_64 && set os_arch amd64 ||
iseq ${os_arch} i386 && set os_arch i386 ||
menu ${os}
{% for item in releases.openbsd.versions %}
item {{ item.code_name }} ${space} ${os} {{ item.name }}
{% endfor %}
choose ver || goto openbsd_exit
{% for item in releases.openbsd.versions %}
iseq ${ver} {{ item.code_name }} && set image_ver {{ item.image_ver }} ||
{% endfor %}
goto boot_openbsd

:boot_openbsd
iseq ${platform} pcbios && goto pcbios_boot ||
iseq ${platform} efi && goto efi_boot ||

:pcbios_boot
set src ${openbsd_mirror}/${openbsd_base_dir}/${ver}/${os_arch}/cd${image_ver}.iso
imgfree
initrd ${src}
chain ${memdisk} iso raw
goto openbsd_menu

:efi_boot
set src ${openbsd_mirror}/${openbsd_base_dir}/${ver}/${os_arch}/install${image_ver}.img
imgfree
sanboot ${src}
goto openbsd_menu

:openbsd_exit
clear menu
exit 0
